﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DataAccessLayer;

public partial class web_Controls_ctrl_vl_left_xkld_list : System.Web.UI.UserControl
{
    Common _common = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        _common = new Common();
        LoadQuocgia();
    }
    void LoadXKLDBy(string qg)
    {
        string _sql = "select A.*, B.ten_quoc_gia from TinTuc_xuat_khau_lao_dong as A inner join DanhMuc_quoc_gia as B on A.ma_quoc_gia = B.ma_quoc_gia where A.ma_quoc_gia = '" + qg + "'";
        DataSet _ds = _common.ExeceuteDataset(_sql);
        rpt_xkld.DataSource = _ds;
        rpt_xkld.DataBind();
        lbl_quocgia_tt.Text = _ds.Tables[0].Rows[0]["ten_quoc_gia"].ToString();
    }
    void LoadQuocgia()
    {
        string _sql = "select * from DanhMuc_quoc_gia as B inner join (select ma_quoc_gia from TinTuc_xuat_khau_lao_dong group by ma_quoc_gia ) as A on A.ma_quoc_gia = B.ma_quoc_gia";
        DataSet _ds = _common.ExeceuteDataset(_sql);
        rpt_quocgia.DataSource = _ds;
        rpt_quocgia.DataBind();
        if (Request.Params["id"] == null)
        {
            if (_ds.Tables[0].Rows.Count>0)
            {
                LoadXKLDBy(_ds.Tables[0].Rows[0]["ma_quoc_gia"].ToString());
            }
        }
        else
        {
            LoadXKLDBy(_common.TextFormat(Request.Params["id"].ToString()));
        }
    }
}
